<template>
  <div>
    <h1>根组件</h1>
    <button @click="fn">校验</button>
    <hr />
    <!-- 2. 关联DOM -->
    <Form ref="formRef" />
  </div>
</template>

<script setup>
import { ref } from 'vue';
import Form from './components/form.vue';
// 1. 提供一个ref
let formRef = ref(null);

const fn = () => {
  // 3. 通过ref访问DOM对象
  console.log('formRef', formRef.value);
  console.log('formRef', formRef.value.money);
  formRef.value.validate();
};
</script>
